package Operation;

import Book.BookList;
import Book.Book;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:查找书籍
 * User: 86184
 * Date: 2023-02-18
 * Time: 15:19
 */
public class FindOperation implements IOperation{
    public void work(BookList bookList){
        System.out.println("请输入查找的图书的书名");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();

        int currentSize=bookList.getUseSize();
        for (int i = 0; i <currentSize ; i++) {
            Book book=bookList.getPos(i);
            if(name.equals(book.getName())){
                System.out.println("找到了这本书！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书！");
    }
}
